// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init()
const db = cloud.database();
// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()
  let id = event.typeId;
  if(event.mycode == 5){
    let res = await db.collection('list_1').where({
      recipeTypeId:id,openid:wxContext.OPENID
    }).get();
    return res
  }
  if(id == ''){
    let res = await db.collection('list_1').orderBy('views','desc').get();
    return res;
  }
  let res = await db.collection('list_1').where({
    recipeTypeId:id
  }).get();
  return res
}